package com.llist;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;

public class LList {

    public static void main(String[] args) {
        LinkedList<String> linkedList = new LinkedList<String>();
        linkedList.add("100");//尾插,等价于 linkedList.addLast()
        linkedList.add("200");
        linkedList.add("300");
       //*******中间插入linkedList..add(3,"700")*************
        linkedList.add("400");
        linkedList.add("500");
        linkedList.add("600");
        System.out.println(linkedList);
        linkedList.add(3,"700");//中间插入
        System.out.println(linkedList);
        //*******修改***************************************
        linkedList.set(3,"700000000");
        System.out.println(linkedList);
        //*******查询***************************************
        System.out.println(linkedList.getFirst());//头查
        System.out.println(linkedList.getLast());//尾插
//        for(int s=0;s<linkedList.size();s++){
//            System.out.println(linkedList.get(s));//随机插
//        }

        //*******移除***************************************
        LinkedList<String> linkedListRemove = new LinkedList<String>();
        linkedListRemove.add("100");
        linkedListRemove.add("200");
        linkedListRemove.add("300");
        linkedListRemove.remove(1);//指定移除
        linkedListRemove.removeAll(linkedList);//也调用上面的unlink方法；LinkedList.ListItr.remove


    }


}
